import 'package:flutter/services.dart';
import 'package:screen_brightness/screen_brightness.dart';

class ScreenBrightnessUtils {
  static final ScreenBrightnessUtils instance =
      ScreenBrightnessUtils._internal();

  factory ScreenBrightnessUtils() {

    return instance;
  }

  static const channel_name = 'channel_name';
  static const platform = MethodChannel(channel_name);

  ScreenBrightnessUtils._internal();

  Future<void> keepScreen(double screenBrightnessValue)async{
    String result = await platform.invokeMethod('method',[{'screenBrightnessValue': '$screenBrightnessValue'}]);
  }

  ///desc:设置屏幕亮度
  ///params:brightness=0.0-1.0
  Future<void> setBrightness(double brightness) async {
    // keepScreen(brightness);
    await ScreenBrightness().setScreenBrightness(brightness);
  }

  ///desc:获取当前屏幕亮度
  ///params:
  /*Future<double> getBrightness() async {
    return await ScreenBrightness().current;
  }*/

  ///desc:监听屏幕亮度
  ///params:回调
  /*Future<void> onBrightnessChange(Function callBack) async {
    ScreenBrightness().onCurrentBrightnessChanged.listen((event) {
      callBack.call(event);
    });
  }*/

  ///desc:设置屏幕亮度
  ///params:brightness=0.0-1.0
  /*Future<void> resetBrightness(double brightness) async {
    await ScreenBrightness().resetScreenBrightness();
  }*/
}
